<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <link rel="stylesheet" href="./index.css" />
  </head>
  <body>
    <div class="container">
      <nav class="menu">
        <ul>
          <li class="active">Me</li>
          <li>Technical</li>
          <li>
            <a>Other</a>
            <ul class="menu-bar">
              <li>One</li>
              <li>Two</li>
            </ul>
          </li>
          <li>Other</li>
          <li>Other</li>
          <li>Other</li>
          <li>Other</li>
        </ul>
      </nav>
      <div class="header"></div>
      <div class="content"></div>
      <div class="footer"></div>
    </div>
  </body>
  <script>
    let nav = document.querySelector("nav");
    let nav_lis = nav.getElementsByTagName("li");
    for (var i = 0; i < nav_lis.length; i++) {
      let elem = nav_lis[i];
      elem.onclick = () => {
        remote_all_active();
        elem.setAttribute("class", "active");
      };
      elem.onmouseenter = () => {
        console.log("1");
      };
    }

    // 移除所有active
    function remote_all_active() {
      for (var i = 0; i < nav_lis.length; i++) {
        nav_lis[i].removeAttribute("class");
      }
    }
  </script>
</html>
